game_manager
{
	spawn
	{
		
		remapshaderflush
		
		// Game rules
		wm_axis_respawntime	30
		wm_allied_respawntime	20
		wm_number_of_objectives 6
		wm_set_round_timelimit	30

		// Objectives
		// 1: Build the bridge
		// 2: Allied command post
		// 3: Axis command post
		// 4: Bunker Door
		// 5: Cave Stone
		// 6: Forward Spawn

		accum 3 set 2	
		accum 4 set 0
		accum 4 set 0

		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		1	0
		wm_set_main_objective		1	1

		wm_objective_status 1 0 0
		wm_objective_status 2 0 0
		wm_objective_status 2 1 0
		wm_objective_status 3 0 0
		wm_objective_status 3 1 0
		wm_objective_status 4 0 0
		wm_objective_status 4 0 0
		wm_objective_status 5 0 0
		wm_objective_status 5 0 0
		wm_objective_status 6 0 0
		wm_objective_status 6 1 0

		wm_set_main_objective		1	0
		wm_set_main_objective		1	1


		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// Winner on expiration of round timer (0=Axis, 1=Allies)
		wm_setwinner	0

		wait 2000

		setautospawn	"Axis Spawn"	0
		setautospawn	"Allies Spawn"	1

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "fueldump_axis_bridge_stop"
		wm_addteamvoiceannounce 1 "fueldump_allies_bridge_construct"
		wm_addteamvoiceannounce 0 "radar_axis_entrance1_defend"
		wm_addteamvoiceannounce 1 "radar_allies_entrance1_destroy"
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "fueldump_axis_bridge_stop"
		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		wm_teamvoiceannounce 1 "fueldump_allies_bridge_construct"
		wm_teamvoiceannounce 0 "radar_axis_entrance1_defend"
		wm_teamvoiceannounce 1 "radar_allies_entrance1_destroy"
		// *---------------------------------------------------------------------------------*

	}

	trigger bunker_door_breached
	{
		wm_objective_status 		4 1 1
		wm_announce	"Allies have destroyed the Bunker Door"
		accum 4 set 1

		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_entrance1_destroyed"
		wm_teamvoiceannounce 1 "radar_allies_entrance1_destroyed"
		// *---------------------------------------------------------------------------------*

		trigger game_manager checkgame
	}

	trigger cave_door
	{
		wm_objective_status 		5 1 1
		wm_announce	"Allies have breached the cave!"
		accum 5 set 1

		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_entrance2_destroyed"
		wm_teamvoiceannounce 1 "radar_allies_entrance2_destroyed"
		// *---------------------------------------------------------------------------------*

	}

	trigger checkgame
	{
		accum 4 abort_if_not_equal 1
		wm_setwinner 1
		wait 1500
		wm_endround
	}

	trigger allies_flag
	{

		wm_objective_status 		6 1 1
		wm_objective_status 		6 0 0
		
		wm_announce	"Allies capture the forward bunker!"

	}
	
	trigger axis_flag
	{

		wm_objective_status 		6 0 1
		wm_objective_status 		6 1 0

		wm_announce	"Axis capture the forward bunker!"



	}

}

// *********************************************
// **************** CONSTRUCTIBLES *************
// *********************************************

Constructable // scriptname in func_constructible
{
	spawn
	{
		wait 400
		
		// targetname "Constructable" of func_constructible
		trigger Constructable setup

		// Sets the type of destructionclass of the contruction, 1 grenade, 2 satchel, 3 dynamite
		constructible_class 3
	}

	trigger setup
	{
		// targetname "build_place" of func_static
		setstate build_place default
		
		// targetname "Constructable" of func_constructible
		setstate Constructable invisible
	}

	buildstart final
	{
		// targetname "build_place" of func_static		
		setstate build_place default
		
		// targetname "Constructable" of func_constructible		
		setstate Constructable underconstruction
	}

	built final
	{
		// targetname "build_place" of func_static		
		setstate build_place invisible
		
		// targetname "Constructable" of func_constructible
		setstate Constructable default

		// message to all players
		wm_announce "The Rhine Bridge has been repaired."

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "fueldump_axis_bridge_destroy"

		wm_addteamvoiceannounce 1 "fueldump_allies_bridge_constructed"

		wm_teamvoiceannounce 0 "fueldump_axis_bridge_destroy"

		wm_teamvoiceannounce 1 "fueldump_allies_bridge_constructed"

		wm_removeteamvoiceannounce 0 "fueldump_axis_bridge_stop"

		wm_removeteamvoiceannounce 1 "fueldump_allies_bridge_constructed"
		// *---------------------------------------------------------------------------------*


	}

	decayed final
	{
		// targetname "build_place" of func_static		
		setstate build_place default
		
		// targetname "Constructable" of func_constructible
		setstate Constructable invisible
	}

	death
	{
		// targetname "build_place" of func_static
		setstate build_place default 
		
		// targetname "Constructable" of func_constructible
		setstate Constructable invisible 

		// message to all players
		wm_announce "The Rhine Bridge is destroyed."

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "fueldump_axis_bridge_destroy"
		wm_addteamvoiceannounce 1 "fueldump_allies_bridge_construct"

		wm_teamvoiceannounce 0 "fueldump_axis_bridge_damaged"

		wm_teamvoiceannounce 1 "fueldump_allies_bridge_damaged"
		// *---------------------------------------------------------------------------------*

	}

	trigger remove
	{
		// targetname of trigger_objective_info
		setstate construction_toi invisible
		
		// targetname "build_place" of func_static
		setstate build_place invisible
		
		// targetname "Constructable" of func_constructible
		setstate Constructable invisible

		remove
	}
}

//--------------------------------------------------------------------
//--------------------   BUNKER DOOR BARS   --------------------------
//--------------------------------------------------------------------
doorbars // scriptname in func_constructible
{
	spawn
	{
		wait 400
		
		// targetname "doorbars" of func_constructible
		trigger doorbars setup

		// Sets the type of destructionclass of the contruction, 1 grenade, 2 satchel, 3 dynamite
		constructible_class 1
	}

	trigger setup
	{
		// targetname "build_bars" of func_static
		setstate build_bars default
		
		// targetname "doorbars" of func_constructible
		setstate doorbars invisible
	}

	buildstart final
	{
		// targetname "build_bars" of func_static		
		setstate build_bars default
		
		// targetname "doorbars" of func_constructible		
		setstate doorbars underconstruction
	}

	built final
	{
		// targetname "build_bars" of func_static		
		setstate build_bars invisible
		
		// targetname "doorbars" of func_constructible
		setstate doorbars default

		// message to all players
		wm_announce "The Bunker door has been caged."
	}

	decayed final
	{
		// targetname "build_bars" of func_static		
		setstate build_bars default
		
		// targetname "doorbars" of func_constructible
		setstate doorbars invisible
	}

	death
	{
		// targetname "build_bars" of func_static
		setstate build_bars default 
		
		// targetname "doorbars" of func_constructible
		setstate doorbars invisible 

		// message to all players
		wm_announce "The Bunker door has been destroyed."
	}

	trigger remove
	{
		// targetname of trigger_objective_info
		setstate doorbars_toi invisible
		
		// targetname "build_bars" of func_static
		setstate build_bars invisible
		
		// targetname "doorbars" of func_constructible
		setstate doorbars invisible

		remove
	}
}

//--------------------------------------------------------------------
//--------------------   STAIRS   --------------------------
//--------------------------------------------------------------------
stairs // scriptname in func_constructible
{
	spawn
	{
		wait 400
		
		// targetname "stairs" of func_constructible
		trigger stairs setup

		// Sets the type of destructionclass of the contruction, 1 grenade, 2 satchel, 3 dynamite
		constructible_class 2
	}

	trigger setup
	{
		// targetname "build_stairs" of func_static
		setstate build_stairs default
		
		// targetname "stairs" of func_constructible
		setstate stairs invisible
	}

	buildstart final
	{
		// targetname "build_stairs" of func_static		
		setstate build_stairs default
		
		// targetname "stairs" of func_constructible		
		setstate stairs underconstruction
	}

	built final
	{
		// targetname "build_stairs" of func_static		
		setstate build_stairs invisible
		
		// targetname "stairs" of func_constructible
		setstate stairs default

		// message to all players
		wm_announce "The Stairs have been built."
	}

	decayed final
	{
		// targetname "build_stairs" of func_static		
		setstate build_stairs default
		
		// targetname "stairs" of func_constructible
		setstate stairs invisible
	}

	death
	{
		// targetname "build_stairs" of func_static
		setstate build_stairs default 
		
		// targetname "stairs" of func_constructible
		setstate stairs invisible 

		// message to all players
		wm_announce "The Stairs have been destroyed."
	}

	trigger remove
	{
		// targetname of trigger_objective_info
		setstate stairs_toi invisible
		
		// targetname "build_stairs" of func_static
		setstate build_stairs invisible
		
		// targetname "stairs" of func_constructible
		setstate stairs invisible

		remove
	}
}

//--------------------------------------------------------------------
//--------------------   LADDER   --------------------------
//--------------------------------------------------------------------
ladder // scriptname in func_constructible
{
	spawn
	{
		wait 400
		
		// targetname "ladder" of func_constructible
		trigger ladder setup

		// Sets the type of destructionclass of the contruction, 1 grenade, 2 satchel, 3 dynamite
		constructible_class 2
	}

	trigger setup
	{
		// targetname "build_ladder" of func_static
		setstate build_ladder default
		
		// targetname "ladder" of func_constructible
		setstate ladder invisible
	}

	buildstart final
	{
		// targetname "build_ladder" of func_static		
		setstate build_ladder default
		
		// targetname "ladder" of func_constructible		
		setstate ladder underconstruction
	}

	built final
	{
		// targetname "build_ladder" of func_static		
		setstate build_ladder invisible
		
		// targetname "ladder" of func_constructible
		setstate ladder default

		// message to all players
		wm_announce "The Ladder have been built."
	}

	decayed final
	{
		// targetname "build_ladder" of func_static		
		setstate build_ladder default
		
		// targetname "ladder" of func_constructible
		setstate ladder invisible
	}

	death
	{
		// targetname "build_ladder" of func_static
		setstate build_ladder default 
		
		// targetname "ladder" of func_constructible
		setstate ladder invisible 

		// message to all players
		wm_announce "The Ladder have been destroyed."
	}

	trigger remove
	{
		// targetname of trigger_objective_info
		setstate ladder_toi invisible
		
		// targetname "build_ladder" of func_static
		setstate build_ladder invisible
		
		// targetname "ladder" of func_constructible
		setstate ladder invisible

		remove
	}
}


// ================================================
// ============ NEUTRAL COMMAND POST ==============
// ================================================

allied_compost_built
{
	spawn
	{
		wait 400
		trigger allied_compost_built setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0
	}

	buildstart final
	{
		setstate allied_compost_built_model underconstruction
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible
	}

	built final
	{
		setstate allied_compost_built_model default
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible

		trigger allied_compost_built_model enable_allied_features

		enablespeaker allies_compost_sound
	}

	decayed final
	{
		setstate allied_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default
	}

	death
	{
		setstate allied_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default

		trigger allied_compost_built_model disable_allied_features

		disablespeaker allies_compost_sound
	}
}

allied_compost_built_model
{
	spawn
	{
		wait 400
		setstate allied_compost_built_model invisible
	}

	trigger enable_allied_features
	{
		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75
		sethqstatus 1 1

		wm_announce	"Allied Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"

		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"

		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 2 0 2
		wm_objective_status 2 1 1
	}

	trigger disable_allied_features
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0

		wm_announce	"Axis team has destroyed the Allied Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_construct"

		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 2 0 0
		wm_objective_status 2 1 0
	}
}

axis_compost_built
{
	spawn
	{
		wait 400
		trigger axis_compost_built setup

		constructible_class 2
	}

	trigger setup
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0
	}

	buildstart final
	{
		setstate axis_compost_built_model underconstruction
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible
	}

	built final
	{
		setstate axis_compost_built_model default
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible

		trigger axis_compost_built_model enable_axis_features

		enablespeaker axis_compost_sound
	}

	decayed final
	{
		setstate axis_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default
	}

	death
	{
		setstate axis_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default

		trigger axis_compost_built_model disable_axis_features

		disablespeaker axis_compost_sound
	}
}

axis_compost_built_model
{
	spawn
	{
		wait 400
		setstate axis_compost_built_model invisible
	}

	trigger enable_axis_features
	{
		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75
		sethqstatus 0 1

		wm_announce	"Axis Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"

		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"

		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 3 0 1
		wm_objective_status 3 1 2
	}

	trigger disable_axis_features
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0

		wm_announce	"Allied team has destroyed the Axis Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"

		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 3 0 0
		wm_objective_status 3 1 0
	}

}

// ================================================
// ============ BUNKER DOOR ==============
// ================================================

bunker_door
{
	spawn
	{
		wait 200

		constructible_class 3
	}

	death
	{
		trigger game_manager bunker_door_breached
	}
}

// ================================================
// ============ CAVE BOULDER ==============
// ================================================

cave_stone
{
	spawn
	{
		wait 200

		constructible_class 3
	}

	death
	{
		trigger game_manager cave_door
	}
}

// ================================================
// ============ FORWARD SPAWN ==============
// ================================================

forward_spawn
{
	spawn
	{
	// accum 3 set 2	// 0-Axis, 1-Allied
	}


	trigger axis_capture
	{

		accum 3 abort_if_not_equal 1

		accum 3 set 0

		trigger game_manager axis_flag

		setautospawn	"Forward Spawn"	0
		setautospawn	"Allies Spawn"	1

		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_bunker_stop"

		wm_teamvoiceannounce 1 "radar_allies_bunker_capture"

		wm_addteamvoiceannounce 0 "radar_axis_bunker_stop"

		wm_addteamvoiceannounce 1 "radar_allies_bunker_capture"
		// *---------------------------------------------------------------------------------*
	}

	trigger allied_capture
	{

		accum 3 abort_if_not_equal 0

		accum 3 set 1

		trigger game_manager allies_flag

		setautospawn	"Axis Spawn"	0
		setautospawn	"Forward Spawn"	1

		wait 1000

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "radar_axis_bunker_captured"

		wm_teamvoiceannounce 1 "radar_allies_bunker_captured"

		wm_addteamvoiceannounce 0 "radar_axis_bunker_captured"

		wm_addteamvoiceannounce 1 "radar_allies_bunker_captured"
		// *---------------------------------------------------------------------------------*

	}
}